require('es6-promise').polyfill();
export const getListData=(data)=>{
    return {
        type:'GETLISTS',
        data
    }
}
export const getGoodsListData=(data)=>{
    return {
        type:'GETGOODSLISTS',
        data
    }
}

export function fetchList(){
    return dispatch=>{
        var url="http://localhost:3000/news/list";
        return fetch(url,{method:'POST'})
        .then(res=>{
            return res.json()
        })
        .then(data=>{
            dispatch(getListData(data))
        })
    }
}
export function fetchGoodsList(){
    return dispatch=>{
        var url="http://localhost:3000/goods/list";
        return fetch(url,{method:'POST'})
        .then(res=>{
            return res.json()
        })
        .then(data=>{
            dispatch(getGoodsListData(data))
        })
    }
}